package cn.tedu.mall.search.test;

import java.util.Scanner;

public class ChouShu1 {
    public static void main(String[] args) {
        while (true) {
            System.out.println("求第几个丑数：");
            int n = new Scanner(System.in).nextInt();
            long result = f(n);
            System.out.printf("第%d个丑数是：%d\n", n, result);
        }
    }

    private static long f(int n) {
        int count = 0;
        for (long i = 2; ; i++) {
            long tmp = i;
            while (tmp % 2 == 0) tmp /= 2;
            while (tmp % 3 == 0) tmp /= 3;
            while (tmp % 5 == 0) tmp /= 5;
            if (tmp == 1) {
                count++;
                if (count == n) {
                    return i;
                }
            }
        }
    }
}
